

// 分析
// 由于Promise可以把异步操作的流程 按同步流程表达出现(看起来更像同步  1. 发送请求 2.结果处理)

// 优化:
// 致力于将所有的请求整合到一起  => 方便后期管理
// 1. 提前将请求(参数配置)封装到函数中 
// 2. 调用时只用传入对应参数即可  => 返回Promise实例 => 请求有结果之后,改变Promise实例的状态


// function isExistUser(params) { // params => {user}
//     return request({
//         type: "get",
//         url: "http://43.138.81.225/demo/php/isExistUser.php",
//         data: params,
//         dataType: "json",
//     })
// }

// const isExistUser = function (params) { // params => {user}
//     return request({
//         type: "get",
//         url: "http://43.138.81.225/demo/php/isExistUser.php",
//         data: params,
//         dataType: "json",
//     })
// }

// const isExistUser = (params) => { // params => {user}
//     return request({
//         type: "get",
//         url: "http://43.138.81.225/demo/php/isExistUser.php",
//         data: params,
//         dataType: "json",
//     })
// }

// const isExistUser = params => { // params => {user}
//     return request({
//         type: "get",
//         url: "http://43.138.81.225/demo/php/isExistUser.php",
//         data: params,
//         dataType: "json",
//     })
// }

const isExistUser = params => request({
    type: "get",
    url: "http://43.138.81.225/demo/php/isExistUser.php",
    data: params,
    dataType: "json",
});

const isExistPhone = params => request({
    type: "get",
    url: "http://43.138.81.225/demo/php/isExistPhone.php",
    data: params,
    dataType: "json",
});

const isExistEmail = params => request({
    type: "get",
    url: "http://43.138.81.225/demo/php/isExistEmail.php",
    data: params,
    dataType: "json",
});

const register = params => request({
    type: "post",
    url: "http://43.138.81.225/demo/php/register.php",
    data: params,
    dataType: "json",
});

const loginAccount = params => request({
    type: "post",
    url: "http://43.138.81.225/demo/php/login_account.php",
    data: params,
    dataType: "json",
});

const searchAllGoods = params => request({
    type: "get",
    url: "http://43.138.81.225/demo/php/searchAllGoods.php",
    data: params,
    dataType: "json",
});

const searchGoodsOrderLimit = params => request({
    type: "get",
    url: "http://43.138.81.225/demo/php/searchGoodsOrderLimit.php",
    data: params,
    dataType: "json",
});


const searchGoodsByGoodsId = params => request({
    type: "get",
    url: "http://43.138.81.225/demo/php/searchGoodsByGoodsId.php",
    data: params,
    dataType: "json",
});

const addToShoppingCar = params => request({
    type: "post",
    url: "http://43.138.81.225/demo/php/addToShoppingCar.php",
    data: params,
    dataType: "json",
});

const searchShoppingCarByUser = params => request({
    type: "post",
    url: "http://43.138.81.225/demo/php/searchShoppingCarByUser.php",
    data: params,
    dataType: "json",
});

const updateShoppingCarById = params => request({
    type: "post",
    url: "http://43.138.81.225/demo/php/updateShoppingCarById.php",
    data: params,
    dataType: "json",
});

const deleteShoppingCarById = params => request({
    type: "get",
    url: "http://43.138.81.225/demo/php/deleteShoppingCarById.php",
    data: params,
    dataType: "json",
});